package com.fzy.modules.people.service;

import com.fzy.modules.people.dao.UserDao;
import com.fzy.modules.people.entity.User;

import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 用户操作
 */
@Service
public class UserService {
    @Autowired
    UserDao userDao;
    /**
     * 条件查询可用用户  如果loginName为空则查询所有可用用户信息
     * @param loginName
     * @return 用户链表
     */
    public List<User> getUseful(String loginName){
        User user=new User();
        user.setEnabled(1);
        if(loginName!=null){
        	user.setLoginName(loginName);
        }
        return userDao.getUseful(user);
    }
	public User login(User user) {
		user.setPassword(DigestUtils.md5Hex(user.getPassword()));
		return userDao.findUser(user);
	}
	public int findStatusById(User user) {
		user=userDao.findUser(user);
		if(user!=null){
			return user.getEnabled();
		}
		return 0;
	}
	
	
}
